package com.sokal.easycare.modules.shares.entity;

import java.util.List;

import org.hibernate.validator.constraints.Length;

import com.google.common.collect.Lists;
import com.sokal.easycare.common.config.Global;
import com.sokal.easycare.common.persistence.DataEntity;
import com.sokal.easycare.common.utils.StringUtils;
import com.sokal.easycare.modules.cms.entity.Comment;
import com.sokal.easycare.modules.sys.entity.MainUser;

/**
 * 经验分享-结合软文分享、图像、视频Entity
 * @author lihaipei
 * @version 2017-03-30
 */
public class ExperienceSharing extends DataEntity<ExperienceSharing> {
	
	private static final long serialVersionUID = 1L;
	private String title;		// 标题
	private String description;		// 内容描述
	private String imageUrl;		// 封面图路径
	private Integer pointsNumber;		// 点赞数量
	private Integer messageNumber;		// 留言数量
	private Integer browseQuantity;		// 浏览数量
	private List<Comment> leavingMsgList = Lists.newArrayList(); //留言列表
	private List<ExprShareFile> exprShareFiles = Lists.newArrayList(); //图片列表
	private String pointStatus; //是否点赞 0未点赞 1已点赞
	
	public ExperienceSharing() {
		super();
		this.pointsNumber = 0;
		this.messageNumber = 0;
		this.browseQuantity = 0;
	}

	public ExperienceSharing(String id){
		super(id);
	}

	@Length(min=1, max=100, message="标题长度必须介于 1 和 100 之间")
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	@Length(min=1, max=4000, message="内容描述长度必须介于 1 和 4000 之间")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Length(min=0, max=100, message="封面图路径长度必须介于 0 和 100 之间")
	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}
	
	public Integer getPointsNumber() {
		return pointsNumber;
	}

	public void setPointsNumber(Integer pointsNumber) {
		this.pointsNumber = pointsNumber;
	}
	
	public Integer getMessageNumber() {
		return messageNumber;
	}

	public void setMessageNumber(Integer messageNumber) {
		this.messageNumber = messageNumber;
	}
	
	public Integer getBrowseQuantity() {
		return browseQuantity;
	}

	public void setBrowseQuantity(Integer browseQuantity) {
		this.browseQuantity = browseQuantity;
	}

	public List<Comment> getLeavingMsgList() {
		return leavingMsgList;
	}

	public void setLeavingMsgList(List<Comment> leavingMsgList) {
		this.leavingMsgList = leavingMsgList;
	}

	public List<ExprShareFile> getExprShareFiles() {
		return exprShareFiles;
	}

	public void setExprShareFiles(List<ExprShareFile> exprShareFiles) {
		this.exprShareFiles = exprShareFiles;
	}

	public MainUser getCreator() {
		if (createBy != null) {
			if (StringUtils.isNotBlank(createBy.getPortraitPhoto())) {
				if (!createBy.getPortraitPhoto().startsWith("http:")) {
					createBy.setPortraitPhoto(Global.getConfig("fastdfs_file_url")+createBy.getPortraitPhoto());
				}
			}
		}
		return createBy;
	}

	public String getPointStatus() {
		return pointStatus;
	}

	public void setPointStatus(String pointStatus) {
		this.pointStatus = pointStatus;
	}
	
}